package interfaceGrafica;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;

import dominioProblema.Pedra;

public class TransferidorPedra implements Transferable{
	protected static DataFlavor pedraFlavor = new DataFlavor(Pedra.class, "Object Pedra");
	protected static DataFlavor[] supportedFlavors = { pedraFlavor };
	protected Pedra pedra;
	public TransferidorPedra(Pedra pedra) {
	    this.pedra = pedra;
	}

	public DataFlavor[] getTransferDataFlavors() {
	    return supportedFlavors;
	}
	
	@Override
	public boolean isDataFlavorSupported(DataFlavor flavor) {
	    if (flavor.equals(pedraFlavor) || flavor.equals(DataFlavor.stringFlavor))
	    	return true;
	    return false;
	}
	
	@Override
	public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
	    if (flavor.equals(pedraFlavor))
	    	return pedra;
	    else if (flavor.equals(DataFlavor.stringFlavor))
	    	return pedra.getPeca();
	    else
	    	throw new UnsupportedFlavorException(flavor);
	}
}
